/********************************************************************
	TABAL ENGINE - 2012/10/30
	author:		Marc Cuscullola
	
	purpose:	Defines a class that register logs.
*********************************************************************/
#pragma once

#ifndef __UTILITIES_LOGGER__LOGGER_INCLUDED_H__
#define __UTILITIES_LOGGER__LOGGER_INCLUDED_H__

#include "Singleton/Singleton.h"
#include "MathTypes.h"
#include <string>
#include <vector>

#define LOGGER CLogger::GetSingletonPtr()
#define CAPACITY 500

enum ELOG_LEVEL
{
	ELL_NONE = 0,
	ELL_INFORMATION,
	ELL_WARNING,
	ELL_ERROR
};

struct SLog
{
	std::string		m_sLogText;
	ELOG_LEVEL		m_eLogLevel;
	uint32			m_uLogLine;
	bool			m_bLineFeed;
};

class CLogger : public CSingleton<CLogger>
{
public:
	CLogger();
	virtual ~CLogger();

	void							AddNewLog			(ELOG_LEVEL ll, const char* format, ... );
	bool							SaveLogsInFile		();

	inline void						SetCapacity			(uint32 capacity);
	inline uint32					GetCapacity			() const;

	inline void						SetLogLevel			(ELOG_LEVEL ll);
	inline ELOG_LEVEL				GetLogLevel			() const;

	inline const std::vector<SLog>&	GetLogs				() const;
	inline int32					GetNumLogs			() const;
	inline const SLog&				GetLog				( uint32 id ) const;
	inline bool						IsError				() const;
	inline bool						IsWarning			() const;
	inline void						SetPathFile			(const std::string& path);

private:
	std::vector<SLog>		m_vLogs;
	uint32					m_uLinesCount;
	uint32					m_uCapacity;
	ELOG_LEVEL				m_eLogLevel;
	bool					m_bErrors;
	bool					m_bWarnings;
	std::string				m_sPathFile;
};

#endif //__UTILITIES_LOGGER__LOGGER_INCLUDED_H__